<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
	{$LOAD_STYLE.top|raw}
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
			<div class="layui-tab layui-tab-brief" lay-filter="TabBrief">
			    <ul class="layui-tab-title">
			        <li class="layui-this">基本信息</li>
					<li>补充信息</li>
			    </ul>
			    <div class="layui-tab-content ">
					<div class="layui-tab-item layui-show">
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">编号</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
								<input type="text" name="number" value="{$model.number??''}" placeholder="请输入编号" class="layui-input"  verify="must">
								<span class="input-group-addon refresh-btn"><i class="layui-icon layui-icon-refresh"></i></span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">面料分类</label>
							<div class="layui-input-block">
							  <select name="tid" lay-verify="required" verify="must"'>
								<option value=""></option>
								{volist name="type_list" id="v"}
								{if !$action_up}
								<option value="{$v.id}">{$v.name}</option>
								{elseif $v.id == $model.tid}
								<option value="{$v.id}" selected="selected">{$v.name}</option>
								{else/}
								<option value="{$v.id}">{$v.name}</option>
								{/if}
								{/volist}
							  </select>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">供应编号</label>
							<div class="layui-input-block">
							  <input type="text" name="onumber" value="{$model.onumber??''}" placeholder="请输入供应编号" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">供应商</label>
							<div class="layui-input-block">
							  <select name="sup_id" lay-verify="required" verify="must"'>
								<option value=""></option>
								{volist name="$supplier" id="v"}								
								{if !$action_up}
								<option value="{$v.id}">{$v.name}</option>
								{elseif $v.id == $model.sup_id}
								<option value="{$v.id}" selected="selected">{$v.name}</option>
								{else/}
								<option value="{$v.id}">{$v.name}</option>
								{/if}								
								{/volist}
							  </select>
							</div>
						</div>		
						
						<div class="layui-form-item">
							<label class="layui-form-label">品名</label>
							<div class="layui-input-block">
							  <input type="text" name="title" value="{$model.title??''}" placeholder="请输入品名" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">幅宽</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
							    <input type="text" name="breadth" value="{$model.breadth??''}" placeholder="请输入幅宽" class="layui-input"  verify="must">
								<span class="input-group-addon">cm</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">克重</label>
							<div class="layui-input-block">
							    <div class="input-group layui-col-md12">
							    <input type="text" name="square" value="{$model.square??''}" placeholder="请输入克重" class="layui-input"  verify="must">
								<span class="input-group-addon">kg</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md6">
							<label class="layui-form-label">幅宽规格</label>
							<div class="layui-input-block">
								{php}if(!$action_up) $model["side_type"]='实用';{/php}
								{volist name="options.side_type" id="v"}
								{if $v == $model.side_type}
								<input type="radio" name="side_type" title="{$v}" value="{$v}" checked>
								{else/}
								<input type="radio" name="side_type" title="{$v}" value="{$v}">
								{/if}
								{/volist}
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">纸管重量</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="tube" value="{$model.tube??'0'}" placeholder="请输入纸管重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">空差重量</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="emptykg" value="{$model.emptykg??'0'}" placeholder="请输入空差重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md4">
							<label class="layui-form-label">1公斤出</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
								<input type="text" name="kgm" value="{$model.kgm??'0'}" placeholder="一公斤出的米数" class="layui-input"  verify="must">
								<span class="input-group-addon">米</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">供货纸管</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="otube" value="{$model.otube??'0'}" placeholder="请输入纸管重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md3">
							<label class="layui-form-label">供货空差</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="oemptykg" value="{$model.oemptykg??'0'}" placeholder="请输入空差重量" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md4">
							<label class="layui-form-label">退纸管空差</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="rebate_kg" value="{$model.rebate_kg??'0'}" placeholder="退纸管和空差" class="layui-input"  verify="must">
							  <span class="input-group-addon">kg</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">成分</label>
							<div class="layui-input-block">
							  <textarea name="component" placeholder="请输入成分" class="layui-textarea">{$model.component??''}</textarea>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-block">
								{foreach $component as $item}
								<button type="reset" class="layui-btn layui-btn-primary layui-btn-sm" component="{$item.val}">{$item.name}</button>
								{/foreach}
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">备注</label>
							<div class="layui-input-block">
							  <textarea name="remark" placeholder="备注信息" class="layui-textarea">{$model.remark??''}</textarea>
							</div>
						</div>
						
						<div class="layui-form-item layui-col-md3">
							<label class="layui-form-label">排序</label>
							<div class="layui-input-block">
							  <input type="text" name="sort" value="{$model.sort??1000}" placeholder="请输入排序" class="layui-input"  verify="must">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">色卡顺序</label>
							<div class="layui-input-block">
								<input type="checkbox" lay-skin="switch" value="sequence" lay-text="一样|打乱" {if $model.sequence??1 == 1} checked {/if}><input type="hidden" name="sequence" value="{$model.sequence??1}">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">状态</label>
							<div class="layui-input-block">
								<input type="checkbox" lay-skin="switch" value="status" lay-text="启用|禁用" {if $model.status??1 == 1} checked {/if}><input type="hidden" name="status" value="{$model.status??1}">
							</div>
						</div>
						
					</div>
					
					<div class="layui-tab-item">
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">杂色零售价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="price1" value="{$model.price1??'0'}" placeholder="请输入杂色零售价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
					<div class="layui-form-item2 layui-col-md5">
						<label class="layui-form-label">米样零售价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="price4" value="{$model.price4??'0'}" placeholder="请输入1米价格" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
					
						<div class="layui-form-item">
							<label class="layui-form-label">零售加价颜色</label>
							<div class="layui-input-block">
							  <textarea name="markup" placeholder="请输入零售加价颜色" class="layui-textarea">{$model.markup??''}</textarea>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">杂色进货价</label>
							<div class="layui-input-block">
								<div class="input-group layui-col-md12">
							    <input type="text" name="space1" value="{$model.space1??'0'}" placeholder="请输入杂色进货价" class="layui-input"  verify="must">
								<span class="input-group-addon">元</span>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item2 layui-col-md5">
							<label class="layui-form-label">米样进货价</label>
							<div class="layui-input-block">
							  <div class="input-group layui-col-md12">
							  <input type="text" name="space4" value="{$model.space4??'0'}" placeholder="请输入米样进货价" class="layui-input"  verify="must">
							  <span class="input-group-addon">元</span>
							  </div>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">进货加价颜色</label>
							<div class="layui-input-block">
							  <textarea name="markup2" placeholder="请输入进货加价颜色" class="layui-textarea">{$model.markup2??''}</textarea>
							</div>
						</div>
						
					</div>
										
				</div>
			</div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="button" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" verify="submit" lay-filter="save" >
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'jquery', 'uploads','common','mycomm'], function () {
    	let form = layui.form;
    	let $ = layui.jquery;
    	let common = layui.common;
    	let mycomm = layui.mycomm;
		
		mycomm.editSubmit();
		
		$('[name="tube"]').change(function(){
			$('[name="otube"]').val($(this).val());
		});
		
		$('[name="emptykg"]').change(function(){
			$('[name="oemptykg"]').val($(this).val());
		});
		
		$('[name="breadth"]').change(function(){
			let breadth = $('[name="breadth"]').val();
			let square = $('[name="square"]').val();
			if(breadth!='' && square!=''){
				total_kgm(breadth,square);
			}
		});
		
		$('[name="square"]').change(function(){
			let breadth = $('[name="breadth"]').val();
			let square = $('[name="square"]').val();
			if(breadth!='' && square!=''){
				total_kgm(breadth,square);
			}
		});
		
		// 刷新编号
		$('.refresh-btn').click(function(){
			var url="{:U('cloth.Temp/randNumber')}";
			var data={};
			$.post(url,data,function(res){
				if(res.code==200){
					$('[name="number"]').val(res.data.number);
				}
			});
			
		});
		
		// 赋值成分
		$('[component]').click(function(){
			let component=$(this).attr('component');
			$('[name="component"]').html(component);
		});
		
		//自动计算出的米数
		function total_kgm(breadth,square){
			let val = 1000/breadth/square*100;
			$('[name="kgm"]').val(val.toFixed(1));
		}
    })
</script>
{$LOAD_STYLE.bottom|raw}
</body>
</html>